add_library(ttnn_op_data_movement ${LIB_TYPE})
add_library(TTNN::Ops::DataMovement ALIAS ttnn_op_data_movement)

target_precompile_headers(ttnn_op_data_movement REUSE_FROM TT::CommonPCH)
TT_ENABLE_UNITY_BUILD(ttnn_op_data_movement)
set_target_properties(
    ttnn_op_data_movement
    PROPERTIES
        INTERFACE_HEADER_SETS_TO_VERIFY
            api
)

# Globbing non-build files is acceptable for now because devs don't generate packages.
file(
    GLOB_RECURSE kernels
    bcast/device/kernels/*
    concat/device/kernels/*
    common/kernels/*
    fill_pad/device/kernels/*
    fill_rm/device/kernels/*
    fold/device/kernels/*
    gather/device/kernels/*
    copy/device/kernels/*
    moe_expert_token_remap/device/kernels/*
    non_zero_indices/device/kernels/*
    move/device/kernels/*
    pad/device/kernels/*
    permute/device/kernels/*
    reshape_on_device/device/kernels/*
    repeat/device/device/*
    reshape_view/device/device/*
    scatter/device/kernels/*
    sort/device/kernels/*
    split/device/kernels/*
    tilize/device/kernels/*
    sharded/device/kernels/*
    slice/device/kernels/*
    tilize_with_val_padding/device/kernels/*
    transpose/device/kernels/*
    untilize/device/kernels/*
    untilize_with_unpadding/device/kernels/*
)
target_sources(
    ttnn_op_data_movement
    PUBLIC
        FILE_SET api
        TYPE HEADERS
        BASE_DIRS ${FixmeOpAPIDir}
        FILES
            bcast/bcast.hpp
            bcast/bcast_types.hpp
            concat/concat.hpp
            copy/copy.hpp
            copy/device/copy_device_operation.hpp
            fill_pad/fill_pad.hpp
            fill_pad/device/fill_pad_device_operation.hpp
            fill_rm/fill_rm.hpp
            fill_rm/device/fill_rm_device_operation.hpp
            pad/pad.hpp
            permute/permute.hpp
            repeat/repeat.hpp
            reshape_view/reshape.hpp
            reshape_view/reshape_common.hpp
            sharded/interleaved_to_sharded/device/interleaved_to_sharded_op.hpp
            sharded/interleaved_to_sharded/interleaved_to_sharded.hpp
            sharded/reshard/reshard.hpp
            sharded/sharded_to_interleaved/device/sharded_to_interleaved_op.hpp
            slice/slice.hpp
            tilize_with_val_padding/tilize_with_val_padding.hpp
            tilize_with_val_padding/device/tilize_with_val_padding_op.hpp
            transpose/transpose.hpp
            untilize/untilize.hpp
            untilize_with_unpadding/untilize_with_unpadding.hpp
        FILE_SET kernels
        TYPE HEADERS
        BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}
        FILES
            ${kernels}
            reshape_view/device/device/dataflow/reader_reshape_tiled.cpp
            reshape_view/device/device/dataflow/writer_reshape_tiled.cpp
            reshape_view/device/device/rm_reshape_interleaved.cpp
            reshape_view/device/hostdevcommon/common.hpp
            tilize/device/kernels/dataflow/reader_unary_stick_layout_split_rows_interleaved.cpp
            untilize/device/kernels/dataflow/reader_unary_start_id.cpp
            untilize/device/kernels/dataflow/writer_unary_stick_layout_split_rows_multi_core.cpp
            untilize/device/kernels/compute/pack_untilize_variable_num_blocks.cpp
            tilize_with_val_padding/device/kernels/dataflow/reader_unary_pad_dims_split_rows_multicore.cpp
            tilize_with_val_padding/device/kernels/dataflow/reader_unary_pad_multicore_both_dims.cpp
            untilize/device/kernels/compute/common.cpp
            untilize_with_unpadding/device/kernels/dataflow/writer_unary_stick_layout_split_rows_multicore.cpp
            tilize/device/kernels/compute/tilize_wh.cpp
            untilize/device/kernels/compute/pack_untilize.cpp
            untilize_with_unpadding/device/kernels/dataflow/writer_unary_stick_layout_wh_multicore.cpp
            untilize/device/kernels/compute/pack_untilize_wh.cpp
    PRIVATE
        bcast/bcast.cpp
        bcast/bcast_types.cpp
        bcast/device/bcast_device_operation.cpp
        bcast/device/bcast_multi_core_h_program_factory.cpp
        bcast/device/bcast_sharded_h_program_factory.cpp
        bcast/device/bcast_sharded_h_optimised_program_factory.cpp
        bcast/device/bcast_multi_core_w_program_factory.cpp
        bcast/device/bcast_multi_core_hw_program_factory.cpp
        chunk/chunk.cpp
        clone/clone.cpp
        clone/device/clone_device_operation.cpp
        clone/device/clone_program_factory.cpp
        common/common.cpp
        concat/concat.cpp
        concat/device/concat_device_operation.cpp
        concat/device/concat_program_factory.cpp
        concat/device/concat_s2s_tiled_program_factory.cpp
        concat/device/concat_s2s_rm_program_factory.cpp
        concat/device/concat_s2s_multi_program_factory.cpp
        concat/device/concat_s2i_program_factory.cpp
        copy/copy.cpp
        copy/device/copy_device_operation.cpp
        copy/device/copy_program_factory.cpp
        expand/expand.cpp
        fill_pad/device/fill_pad_device_operation.cpp
        fill_pad/device/fill_pad_program_factory.cpp
        fill_pad/fill_pad.cpp
        fill_rm/device/fill_rm_device_operation.cpp
        fill_rm/device/fill_rm_program_factory.cpp
        fill_rm/fill_rm.cpp
        fold/device/fold_device_op.cpp
        fold/device/fold_multi_core_dram_program_factory.cpp
        fold/device/fold_multi_core_program_factory.cpp
        fold/device/fold_single_core_program_factory.cpp
        fold/fold.cpp
        indexed_fill/device/indexed_fill_device_operation.cpp
        indexed_fill/device/indexed_fill_program_factory.cpp
        indexed_fill/indexed_fill.cpp
        moe_expert_token_remap/moe_expert_token_remap.cpp
        moe_expert_token_remap/device/moe_expert_token_remap_device_operation.cpp
        moe_expert_token_remap/device/moe_expert_token_remap_program_factory.cpp
        moe_routing_remap/moe_routing_remap.cpp
        moe_routing_remap/device/moe_routing_remap_device_operation.cpp
        moe_routing_remap/device/moe_routing_remap_program_factory.cpp
        move/device/move_device_operation.cpp
        move/device/move_program_factory.cpp
        move/move.cpp
        non_zero_indices/device/non_zero_indices_device_operation.cpp
        non_zero_indices/device/non_zero_indices_program_factory.cpp
        non_zero_indices/non_zero_indices.cpp
        pad/device/pad_op.cpp
        pad/device/pad_program_factory.cpp
        pad/pad.cpp
        permute/device/permute_device_operation.cpp
        permute/device/permute_rm_program_factory.cpp
        permute/device/permute_tiled_program_factory.cpp
        permute/permute.cpp
        repeat/device/host/repeat_program_factory.cpp
        repeat/device/repeat_device_operation.cpp
        repeat/repeat.cpp
        repeat_interleave/repeat_interleave.cpp
        reshape_on_device/device/reshape_op.cpp
        reshape_on_device/device/reshape_tile_program_factory.cpp
        reshape_on_device/device/reshape_rm_program_factory.cpp
        reshape_on_device/reshape.cpp
        reshape_view/device/reshape_rm_program_factory.cpp
        reshape_view/device/reshape_tiled_program_factory.cpp
        reshape_view/device/reshape_device_operation.cpp
        reshape_view/reshape.cpp
        roll/roll.cpp
        scatter/scatter.cpp
        scatter/tosa_scatter.cpp
        scatter/device/scatter_device_operation.cpp
        scatter/device/scatter_program_factory.cpp
        sharded/interleaved_to_sharded/device/interleaved_to_sharded_op.cpp
        sharded/interleaved_to_sharded/device/interleaved_to_sharded_program_factory.cpp
        sharded/interleaved_to_sharded/interleaved_to_sharded.cpp
        sharded/reshard/device/reshard_device_operation.cpp
        sharded/reshard/device/reshard_program_factory_same_width.cpp
        sharded/reshard/device/reshard_program_factory_same_height.cpp
        sharded/reshard/device/reshard_program_factory_generic.cpp
        sharded/reshard/device/nd_reshard_program_factory_copy_pages.cpp
        sharded/reshard/device/nd_reshard_program_factory_copy_local.cpp
        sharded/reshard/reshard.cpp
        sharded/sharded_common.cpp
        sharded/sharded_to_interleaved/device/sharded_to_interleaved_op.cpp
        sharded/sharded_to_interleaved/device/sharded_to_interleaved_program_factory.cpp
        sharded/sharded_to_interleaved/sharded_to_interleaved.cpp
        sharded_partial/interleaved_to_sharded_partial/device/interleaved_to_sharded_partial_op.cpp
        sharded_partial/interleaved_to_sharded_partial/device/interleaved_to_sharded_partial_program_factory.cpp
        sharded_partial/interleaved_to_sharded_partial/interleaved_to_sharded_partial.cpp
        sharded_partial/sharded_to_interleaved_partial/device/sharded_to_interleaved_partial_op.cpp
        sharded_partial/sharded_to_interleaved_partial/sharded_to_interleaved_partial.cpp
        slice/device/slice_device_operation.cpp
        slice/device/slice_program_factory_rm.cpp
        slice/device/slice_program_factory_rm_sharded.cpp
        slice/device/slice_program_factory_rm_stride.cpp
        slice/device/slice_program_factory_tile.cpp
        slice/device/slice_program_factory_tile_tensor_args.cpp
        slice/slice.cpp
        split/device/split_device_operation.cpp
        split/device/split_program_factory.cpp
        split/split.cpp
        squeeze/squeeze.cpp
        stack/stack.cpp
        tilize/device/tilize_op.cpp
        tilize/device/tilize_program_factory.cpp
        tilize/tilize.cpp
        tilize_with_val_padding/device/tilize_with_val_padding_op.cpp
        tilize_with_val_padding/device/tilize_with_val_padding_program_factory.cpp
        tilize_with_val_padding/tilize_with_val_padding.cpp
        transpose/device/transpose_op.cpp
        transpose/device/transpose_program_factory.cpp
        transpose/transpose.cpp
        unsqueeze/unsqueeze.cpp
        untilize/device/untilize_op.cpp
        untilize/device/untilize_program_factory.cpp
        untilize/untilize.cpp
        untilize_with_unpadding/device/untilize_with_unpadding_op.cpp
        untilize_with_unpadding/device/untilize_with_unpadding_program_factory.cpp
        untilize_with_unpadding/untilize_with_unpadding.cpp
        view/view.cpp
        sort/sort.cpp
        sort/device/sort_device_operation.cpp
        sort/device/sort_program_factory.cpp
        gather/gather.cpp
        gather/device/gather_device_operation.cpp
        gather/device/gather_program_factory.cpp
        gather/tosa/gather_tosa.cpp
)

target_include_directories(ttnn_op_data_movement PRIVATE ${FixmeOpIncDirs})
target_link_libraries(ttnn_op_data_movement PUBLIC TTNN::Core PRIVATE TT::Metalium)

install(
    TARGETS
        ttnn_op_data_movement
    FILE_SET
    api
        COMPONENT ttnn-dev
    FILE_SET
    kernels
        DESTINATION ${CMAKE_INSTALL_LIBEXECDIR}/tt-metalium/ttnn/cpp/ttnn/operations/data_movement
        COMPONENT ttnn-runtime
)

install(TARGETS ttnn_op_data_movement LIBRARY COMPONENT tar)
